
local locplayer = ac.player.self
local w,h = 450,300
local ui = class.panel:builder 
{
    x = (1920 - w)/2,
    y = 300,
    w = w,
    h = h,
    show_flag = false,
    alpha = 0.99,
    level = 99,
    fdf = 'tooltip_backdrop0',
}
ui:set_level(99)
ui.title = ui:add_text('|cffffff00替换天赋|r',0,5,nil,30,12,5)
ui.icon = ui:add_card_button((ui.w-64)/2,40,64,64)
ac['符文替换'] = ui

local normal_icon = [[core/emptyinvslot1.blp]]
local w1,h1 = 64,64
local x1 = 20
local y1 = 200
ui.buttons = {}

for a=1,6 do
    local x = (a-1) * (w1 + 5) + x1
    local panel = ui:add_card_button(x,y1,w1,h1)
    panel.index = a
    table.insert(ui.buttons,panel)
end

function ui:update()
    local data = self._card_list or {}
    local temp = self._card_temp
    self.icon:set_data(temp)
    for i,button in ipairs(self.buttons) do
        local skill = data[i]
        button:set_data(skill)
    end
end

function ui:on_button_mouse_enter(button)
    local skill = button.skill
    if skill then
        button:tooltip(skill:get_title(),skill:get_tip())
    end
end

function ui:on_button_clicked(button)
    if button==self.esc then
        self:hide()
        return
    end
    ac.sync('同步-替换符文',button.index)
    self:hide()
end

function ui:set_data(data,temp)
    self._card_list = data
    self._card_temp = temp
    self:update()
    self:show()
end
